package performanceTester;

import java.util.ArrayList;

public class Performance {

    private static long time1, time2;
    private static ArrayList<Long> timeList = new ArrayList<Long>();

    /*
     * Usage:
     * 
     * Use these two Methods to calc Performance
     * Performance.setTime1(); to set the start time
     * Performance.setTime2(); to set the end time
     * the setTime2-Method also adds the time, it took until both methods were called, to an List
     * 
     * Always put a TODO line above the performance code you added like this one:
     * //TODO remove after finishing the Performance Test
     * 
     * Only in PerformanceGUI needed!!
     * Performance.getDurchschnittsZeit(); to calc the average-time and return it
     */
    
    
    public static void setTime1() {
        time1 = System.nanoTime();
    }

    public static void setTime2() {
        time2 = System.nanoTime();
        long temp = time2 - time1;
        timeList.add(temp);
    }

    public static long getDurschnittsZeit() {
        long durchschnitt = 0;
        for (int i = 0; i < timeList.size(); i++) {
            durchschnitt += timeList.get(i);
        }
        durchschnitt /= timeList.size();
        return durchschnitt;
    }
}
